﻿using System;
using System.Collections.Generic;
using System.Diagnostics;

namespace ZZQFrameWork.AI
{
    /// <summary>
    /// 是否有目标
    /// </summary>
    public class IsHasTarget : ConditionNode
    {
        public override Enum_BTState Proc(EntityParent owner)
        {
            //UnityEngine.Debug.Log("是否有目标");
            if (owner.SelectNode == null)
            {
                owner.blackBoard.Enemy = null;
                return Enum_BTState.Failure;
            }
            owner.blackBoard.Enemy = owner.SelectNode.goods;
            return Enum_BTState.Success;
        }
    }

    /// <summary>
    /// 目标是否是怪物
    /// </summary>
    public class IsTargetMonster : ConditionNode
    {
        public override Enum_BTState Proc(EntityParent owner)
        {
            //UnityEngine.Debug.Log("是否是怪物");
            if (owner.SelectNode.isMonster) return Enum_BTState.Success;
            return Enum_BTState.Failure;
        }
    }

    /// <summary>
    /// 是否在目标周围
    /// </summary>
    public class IsNearTarget : ConditionNode
    {
        public override Enum_BTState Proc(EntityParent owner)
        {
            //UnityEngine.Debug.Log("是否在目标周围");
            if (Map.Instance.aStar.GetNeibourhood(owner.SelectNode).Contains(owner.nowNode))
                return Enum_BTState.Success;
            return Enum_BTState.Failure;
        }
    }

    /// <summary>
    /// 是否正在释放技能
    /// </summary>
    public class IsFreedSkil:ConditionNode
    {
        public override Enum_BTState Proc(EntityParent owner)
        {
            if (owner.ProcIsDoSkill() == null)
            {
                owner.blackBoard.NowSkillId = 0;
                return Enum_BTState.Failure;
            }
            return Enum_BTState.Success;
        }
    }

    /// <summary>
    /// 是否有需要释放的技能
    /// </summary>
    public class IsHasNeedFreedSkill : ConditionNode
    {
        public override Enum_BTState Proc(EntityParent owner)
        {
            if (owner.ProcHasNextSkill() == null)
            {
                owner.blackBoard.NeedSkillId = 0;
                return Enum_BTState.Failure;
            }
            return Enum_BTState.Success;
        }
    }

    /// <summary>
    /// 需要释放的技能是否在冷却当中
    /// </summary>
    public class IsSkillInCold : ConditionNode
    {
        public override Enum_BTState Proc(EntityParent owner)
        {
            if(owner.ProcIsNextSkillInColdTime())return Enum_BTState.Success;
            return Enum_BTState.Failure;
        }
    }

    /// <summary>
    /// 是否处于移动/无法移动当中
    /// </summary>
    public class IsInMove : ConditionNode
    {
        public override Enum_BTState Proc(EntityParent owner)
        {
            if (owner.blackBoard.AIState == AIState.MOVE_STATE || owner.blackBoard.AIState == AIState.FIGHT_STATE)
            {
                UnityEngine.Debug.Log("正在移动或者战斗中，无法再次移动");
                return Enum_BTState.Success;
            }
            return Enum_BTState.Failure;
        }
    }

    /// <summary>
    /// 是否寻路成功
    /// </summary>
    public class IsFindPath : ConditionNode
    {
        public override Enum_BTState Proc(EntityParent owner)
        {
            //UnityEngine.Debug.Log("是否寻路成功");
            if(owner.findPathList!=null&&owner.findPathList.Count>0)return Enum_BTState.Success;
            return Enum_BTState.Failure;
        }
    }

    /// <summary>
    /// 是否处于攻击cd
    /// </summary>
    public class IsInAttackCold : ConditionNode
    {
        public override Enum_BTState Proc(EntityParent owner)
        {
            if(owner.blackBoard.AIState==AIState.FIGHT_CD_STATE)return Enum_BTState.Success;
            return Enum_BTState.Failure;
        }
    }

    public class ConditionNodes
    {
    }
    }

